﻿// Learn more about F# at http://fsharp.net
open CoqAuWin.Main
open Coq.MonoDevelop.SimpleParser
open Ast
open System
open System.IO
open System.Text

let getSentences fileName = 
    let castl = Coq.MonoDevelop.SimpleParser.ParseFile(fileName).Value 
    match castl with 
    | SimpleCoqAST(a) -> a |> List.map (fun a ->
        match a with 
        | (s,l) -> s 
        )

let parseFile fn = 
    
    let p = CoqAuWin.Main.ParseDbg(File.ReadAllText fn)
    //let p = CoqAuWin.Main.Parse(s)
    
    match p with
    | Some(a) -> printfn "OK\n"
    | None -> printfn "Error\n"
    

let parseSentence s = 
    printfn "%A\n -------------------------------" s
    let p = CoqAuWin.Main.ParseDbg(s)
    //let p = CoqAuWin.Main.Parse(s)
    
    match p with
    | Some(a) -> printfn "OK\n"
    | None -> printfn "Error\n"

let Tests() = 
    let dir = new DirectoryInfo("..\\..\\Tests")

    if (dir = null || not dir.Exists) then
        []
    else
        for f in (dir.GetFiles()) do
            printfn "FILE:--------------%A---------------------" (f.ToString().ToUpper())
            //parse whole file
            parseFile f.FullName |> ignore
            //parse as sentences
            //let s = getSentences f.FullName
            //List.map parseSentence s |> ignore
            Console.ReadLine() |> ignore
            Console.Clear()
        []

//let s = null
//if s = null then printf "test" else printf "bleh"
//printfn "%A" (CoqAuWin.Main.ParseFile("testcoqscript.txt"));
//printfn "%A" (ParseFile("testcoqscript.txt"));
 
//CoqAuWin.Main.Test()
//Test();
//CoqAuWin.Main.Test();

Tests()

